#define _CRT_SECURE_NO_WARNINGS 1
#include<stdlib.h>
#include<stdio.h>

char** findRelativeRanks(int* score, int scoreSize, int* returnSize) {
    char** ret = (char**)malloc(sizeof(char*) * scoreSize);
    int winner = 0, i = 0, j = 0, count = 0;
    for (j = 0; j < scoreSize; j++)
        ret[j] = (char*)malloc(sizeof(char) * 15);
    int spei = scoreSize;
    for (j = 0; j < scoreSize; j++)
        if (score[j] == 0)
            spei = j;
    for (j = 0; j < scoreSize; j++) {
        for (i = 1; i < scoreSize; i++)
            if (score[i] >= score[winner])
                winner = i;
        score[winner] = 0;
        count++;
        if (count == scoreSize && spei != scoreSize)
            winner = spei;
        if (count == 1)
            sprintf(ret[winner], "%s", "Gold Medal");
        else if (count == 2)
            sprintf(ret[winner], "%s", "Silver Medal");
        else if (count == 3)
            sprintf(ret[winner], "%s", "Bronze Medal");
        else
            sprintf(ret[winner], "%d", count);
        winner = 0;
    }
    *returnSize = scoreSize;
    return ret;
}

int main()
{
    int a[] = { 10,3,8,9,4 };
    int returnSize = 0;
    char** ret = findRelativeRanks(a, 5, &returnSize);
    for (int i = 0; i < returnSize; i++)
    {
        printf("%s ", ret[i]);
    }
    return 0;
}